home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / AMIGA / AMICUS / AMICUS22.ADF / BasicSorts / BinarySearch.DOC < prev    next >
Text File  |  1987-06-30  |  1KB  |  31 lines

  1.    This is the fastest algorithm that I know of for searching through
  2. a sorted list for a certain string.  If anyone would like to know more about
  3. why it works, just drop me a line to the address listed at the end of this
  4. document file.
  5.    To search for a string just call the BinarySearch subprogram like this:
  6.  
  7.          Call BinarySearch ( Upper%, M$(), T$, P% )
  8.  
  9. where Upper% is the upper limit of the array, M$() is the array to be
  10. searched through, T$ is the string to be searched for in M$().  P% is
  11. returned 0 by the sub if T$ is not in M$(1..Upper%).  P% is returned greater
  12. than zero if M$(P%) = T$.  Then you have the index of the first occurance of
  13. T$ in M$(1..Upper%).
  14.  
  15. NOTE :-
  16.  
  17.       Upper%     :  can be a number or an integer variable
  18.       M$()       :  must be a variable name of a string array
  19.       T$         :  must be a variable name of a string
  20.       P%         :  must be a variable name of an integer
  21.  
  22. For more information just write me at:
  23.  
  24.       Gregory A. Kendall
  25.       ATN/ Brendallson Software
  26.       522 Neese Road
  27.       Woodstock, GA  30188
  28.  
  29. Auf Wiedersehen!
  30.  
  31.